package com.fangcang.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mvc")
public class SpringMvcController {

	/**
	 * 只接收包含参数method=get的请求
	 * 如果params有多个参数，则请求中必须同时包含多个参数
	 * @return
	 */
	@RequestMapping(value="test",  params = {"method=get", "action"})
	public String getParam(@RequestParam("method") String method) {
		return method;
	}
	
	/**
	 * 只接收包含参数method=get的请求
	 * @return
	 */
//	@RequestMapping(value="test", params = {"method=get2"})
//	public String getParam2(@RequestParam("method") String method) {
//		return method;
//	}
	
	
	@RequestMapping(value="test2", params = {"method=test"})
	public Map<String, String> getParam3(@RequestParam("method") String method) {
		Map<String, String> result = new HashMap<String, String>();
		result.put("method", method);
		result.put("action", "actions");
		return result;
	}
	
}
